var layer;
layui.use(["layer"],function(){
	layer = layui.layer;		//取出弹出层模块对象
	//layer.msg("弹窗内容");		//迷你弹窗
});
$(document).ready(function(){
	var myCaptcha = _dx.Captcha(document.getElementById('c1'), {
				    appId: '9be12d3c3104f8574fdd5d545f715df8', //appId，在控制台中“应用管理”或“应用配置”模块获取
				    success: function (token) {
				      //console.log('token:', token)
				      $.ajax({
				      	type:"get",
				      	//url:"/Xphp/CaptchaDemo.php?token="+token,
				      	url:"/yzm.php?token="+token,
				      	success:function(msg){
				      		console.log(msg);
				      		if(msg=='SERVER_SUCCESStrue')
				      		{
				      			$("#dlbtn").attr("kg","yes");
				      			$("#tj").css("display","none");
				      			$("#dlbtn").css("background", "rgb(189,13,24)");
				      			$("#dlbtn").css("color", "white");
				      			
				      		}
				      	}
				      });
				    }
				})
			
			/*myCaptcha.on('passByServer',function(token) {
				    console.log(token);
			});*/
	
	
	
	
	
	$("#dlbtn").click(function(){
		
		if($(this).attr("kg")=="yes")
		{
			$.ajax({
				type:"post",
				url:"/ajax.php?ajax=sylogin",
				dataType:"json",
				data:{
					name:$("#name").val(),
					pwd:$("#pwd").val()
				},
				success:function(mgs){
					if (mgs.code==0)
	                {
	                    alert(mgs.info);
	                }else{
	                    window.location.href="/sy"+mgs.code+".php";
	                    alert(mgs.info);
	                }
				}
			})
		}
		
		
	});
	$("#yzbtn").click(function(){
		//$("#c1").css("display","block");
		
		$("#tj").css("display","block");
	});
	
	$("#tj_1_1_1").click(function(){
		$("#tj").css("display", "none");
	});
	
});